package com.wzqj.agent.app.version.controller;

import com.alibaba.fastjson.JSONObject;
import com.wzqj.agent.app.login.controller.AuthRequiredController;
import com.wzqj.agent.app.version.service.VersionService;
import com.wzqj.agent.common.JsonOutput;
import com.wzqj.agent.common.exception.BusinessErrorType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by wanghao@weipass.cn on 2015/8/3.
 */
@Controller
@RequestMapping("/api/version")
public class ApiVersionController {

    @Autowired
    private VersionService versionService;

    @RequestMapping("/check")
    @ResponseBody
    public JSONObject checkAppUpdate(String mt,String versionCode)	{

        JsonOutput output = new JsonOutput();
        JSONObject data = versionService.check(mt, versionCode);
        if (data == null){
            output.setErrCode(BusinessErrorType.VERSION_INFO_CHECK_ERROR.getErrCode());
            output.setMsg(BusinessErrorType.VERSION_INFO_CHECK_ERROR.getErrMsg());
            return output.toJSONObject();
        }
        output.setData(data);
        return output.toJSONObject();
    }

}
